package com.bestseller.action;

import java.util.List;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.interceptor.ServletRequestAware;

import com.bestseller.bean.SysUserGroupSearch;
import com.bestseller.bean.form.SysUserGroupForm;
import com.bestseller.contain.ServicePoint;
import com.bestseller.pojo.SysUserGroup;
import com.bestseller.service.UserGroupService;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

@SuppressWarnings("serial")
public class SysUserGroupAction extends ActionSupport implements ModelDriven<SysUserGroupForm>,ServletRequestAware{
	private SysUserGroupForm form=new SysUserGroupForm();
	private ServletRequest request;
	//spring加载service
	private UserGroupService service=(UserGroupService) ServicePoint.getService(UserGroupService.SERVICE_NAME);
	
	public String list(){
		SysUserGroupSearch search=new SysUserGroupSearch();
		search.setName(form.getName());
		
		List<SysUserGroup> SysUserGroupList=service.getList(search);
		
		request.setAttribute("SysUserGroupList", SysUserGroupList);
		return "list";
	}

	@Override
	public SysUserGroupForm getModel() {
		return form;
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request=request;
	}
}
